<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>展开操作符</h2>
    <ul class="box">
        <li>item1</li>
        <li>item2</li>
        <li>item3</li>
        <li>item4</li>
        <li>item5</li>
    </ul>
</body>
<script>
    //1.展开操作
    const obj1={name:'jack',age:10}
    const obj2={address:'北京',birth:'2004.8'}

    const res={...obj1,...obj2}
  
    const arr1=['vue','react']
    const arr2=['angular','vite']

    //2.剩余操作 

    function qiuhe(title,...res) {
        console.log('title:',title)
        console.log('res:',res)
       // console.log(res)
        // for(var i=0,sum=0;i<res.length;i++) {
        //     sum+=res[i]
        // }

        // return sum;
    //arguments伪数组，也称类数组  Array.from()
    // Array.from(arguments).forEach(item=>{
    //        console.log(item) 
    //     })
    }

   console.log(qiuhe('对数组求和',1,3,5)) 

   const allLi=document.querySelectorAll('.box>li')
   //const resultArr=Array.from(allLi)
   const resultArr=[...allLi]
   resultArr.push('2302A')

   console.log(resultArr)

</script>
</html>